home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 0758 / setup.arv / MARKPROD.TEM < prev    next >
Encoding:
Text File  |  1997-04-10  |  3.5 KB  |  117 lines

  1. #
  2. # mark the choices sent by the form for the current item in the session db
  3. # marker Title 
  4.         $TITLE="Catalog Maker Product Mark";
  5. ###############################
  6. # END OF CHANGEABLE OPTIONS   #
  7. ###############################
  8.  
  9. # START MAIN PROGRAM 
  10. # ------------------
  11.  
  12. &ReadParse;
  13. $Session = $in{'SessionID'};
  14. if    ($Session eq '')               {&PrintError; exit 1;}  # An Error
  15. elsif ($Session eq '*SeSiOnId*')     {&PrintError; exit 1;};  # Get a session id
  16.  
  17. $targetFile = $ENV{'PATH_TRANSLATED'};
  18. $ItemID = $in{'ItemID'};
  19.  
  20. print "Content-Type: text/html\n\n";
  21. print "<HTML><HEAD><TITLE>$TITLE</TITLE></HEAD><BODY BGCOLOR=#ffffff>";
  22.         
  23. if (!dbmopen(%subs, "items", 0777)) {
  24.         print "Error: Can not read items database</BODY></HTML>";
  25.         exit 1;
  26. }
  27.  
  28. if (!dbmopen(%items, "$Session", 0777)) {
  29.         print "Error: Can not open session data</BODY></HTML>";
  30.         exit 1;
  31. }
  32.  
  33. if (!dbmopen(%prices, 'prices', 0777)) { 
  34.         print "Error: Can not open price database</BODY></HTML>";
  35.         exit 1;
  36. }
  37.  
  38. $totalOrder = $items{'TotalOrder'};
  39. $totalProducts = $items{'TotalProducts'};
  40. $totalWeight = $items{'TotalWeight'};
  41.  
  42. $subItems = $subs{$ItemID};
  43. if ($subItems != "") {
  44.         for ( $si = 1; $si <= $subItems; $si++ ) {
  45.                 $TheSubItem = $ItemID . $si;
  46.                 $TheValue = $in{$TheSubItem};
  47.                 $totalProducts = $totalProducts - $items{$TheSubItem} + $TheValue; # total # of products ordered
  48.                 $totalOrder = $totalOrder + (($TheValue - $items{$TheSubItem}) * $prices{$TheSubItem}); # the total order
  49.                 $totalWeight = $totalWeight + (($TheValue - $items{$TheSubItem}) * $prices{$TheSubItem . "W"}); # the total order
  50.                 $items{$TheSubItem} = $TheValue;
  51.         } # for 
  52. } # there are sub items 
  53.  
  54. $items{'TotalOrder'} = $totalOrder;
  55. $items{'TotalWeight'} = $totalWeight;
  56. $items{'TotalProducts'} = $totalProducts;
  57.  
  58. dbmclose(%prices);
  59. dbmclose(%items);
  60. dbmclose(%subs);
  61.  
  62. $TargetPage = $in{'TargetPage'};
  63. $TargetScript = $in{'TargetScript'};
  64.  
  65. print "The products you specified were marked!<br>";
  66. print "So far you marked $totalProducts products for a total of \$ $totalOrder <br>";
  67. print "The total weight of the products you ordered is $totalWeight <br>";
  68. print "<a href=\"$TargetScript$TargetPage?SessionID=$Session&ItemID=$ItemID\">Continue</a>";
  69.  
  70. print "</BODY></HTML>";
  71.  
  72. exit(1);
  73.  
  74. # GENERAL SUBROUTINES
  75. # -------------------
  76.  
  77. sub ReadParse {
  78.   local (*in) = @_ if @_;   local ($i, $loc, $key, $val);
  79.   if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'}; } 
  80.   elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); }
  81.   @in = split(/&/,$in);
  82.   foreach $i (0 .. $#in) {
  83.     $in[$i] =~ s/\+/ /g;
  84.     ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
  85.     $key =~ s/%(..)/pack("c",hex($1))/ge;
  86.     $val =~ s/%(..)/pack("c",hex($1))/ge;
  87.     $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator
  88.     $in{$key} .= $val;
  89.   }
  90.   return 1; # just for fun
  91. } # ReadParse
  92.  
  93. sub PrintError {
  94. print("Content-Type: text/html\n\n");
  95. print <<EOF;
  96. <HTML> 
  97. <HEAD><TITLE>ERROR</TITLE></HEAD>
  98. <BODY>
  99. <H1 ALIGN=CENTER>$TITLE</H1>  <HR>
  100. An error occured in the script!
  101. <HR>
  102. EOF
  103. } # PrintError
  104.  
  105. sub PrintSuccess {
  106. print <<EOF;
  107. <HTML> 
  108. <HEAD><TITLE>Success</TITLE></HEAD>
  109. <BODY>
  110. <H1 ALIGN=CENTER>$TITLE</H1>  <HR>
  111. Your request was processed succesfuly!
  112. Thank you for using a catalog maker product!
  113. <HR>
  114. EOF
  115. } # PrintSuccess
  116.  
  117.